package com.quanquan.user.repository;

import com.quanquan.user.entity.SignInRule;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

/**
 * 功能描述:
 *
 * @ClassName: SignInRuleRepository
 * @Author: xiaoqianh丶
 * @Date: 2019-04-05 21:51
 * @Version: V1.0
 */
public interface SignInRuleRepository extends JpaRepository<SignInRule, String>{

    /**
     * 根据签到规则应用状态查询规则
     * @param useStatus
     * @return
     */
    public SignInRule findByUseStatus(Boolean useStatus);


    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(value="update oo_sign_in_rule set status_use='N' where id !=?1" ,nativeQuery=true)
    public void removeUseStatus(String foreignKeyId);



    public SignInRule findByIdAndRemove(String signInRuleId,Boolean remove);
}
